<!--User.vue.vue-->
<template>
  <div class="">
    <div class="big_div">
      <h3>我的</h3>
      <div class="cell_align cell_header" @click="getUserAccount">
        <mt-cell
          title="tingyuegtc"
          label=""
          is-link
          value="">
          <img slot="icon" src="../assets/account.png" width="40" height="40">
        </mt-cell>
      </div>

      <div class="cell_align">
        <mt-cell
          title="已完成的任务"
          to="/overTask"
          is-link
          value="">
        </mt-cell>
        <mt-cell
          title="正在执行的任务"
          to="/doingTask"
          is-link
          value="">
        </mt-cell>
        <mt-cell
          title="已报名的任务"
          to="/joinTask"
          is-link
          value="">
        </mt-cell>
        <mt-cell
          title="我发布的任务"
          to="publishTask"
          is-link
          value="">
        </mt-cell>
      </div>

      <div class="cell_align">
        <mt-cell
          title="系统推荐任务"
          to="/recommendTask"
          is-link
          value="">
        </mt-cell>
      </div>

      <!-- <div class="cell_align">
        <mt-cell
          title="我的活动"
          to=""
          is-link
          value="">
        </mt-cell>
      </div> -->
    </div>

    <tab-bar></tab-bar>
  </div>

</template>


<script>
import axios from 'axios';
import { Toast } from 'mint-ui';
import storeItem from '../utils/store';
import tabBar from './common/TabBar';

axios.defaults.baseURL = process.env.BASE_URL;
console.log(process.env.BASE_URL);

export default {
  name: 'user',
  data() {
    return {
      user: {},
    };
  },
  methods: {
    getUserInfo() {
      axios.get('/user/user_detail', {
        params: {
          token: storeItem.getItem('token'),
        },
      }).then((response) => {
        if (response.status === 200) {
          if (response.data.status === true) {
            this.user = response.data.data;
          }
        }
      });
    },
    getUserAccount() {
      axios.get('/user/amount', {
        params: {
          token: storeItem.getItem('token'),
        },
      }).then((response) => {
        if (response.status === 200 && response.data.status === true) {
          Toast({
            message: `账户余额: ${response.data.data.cash}`,
            duration: 1500,
          });
        }
      });
    },
  },
  mounted() {
    this.getUserInfo();
  },
  components: {
    'tab-bar': tabBar,
  },
};
</script>

<style>
  .cell_align {
    /*padding: 5%;*/
    text-align: justify;
    /*margin-bottom: 4%;*/
  }
  .cell_header {
    font-size: 15px;
    padding-left: 20px;
    /*margin-top: 3%;*/
  }

</style>
